﻿using FluentNHibernate.Mapping;
using cludg.Domain.Content.Stories;
using cludg.Domain.Users;

namespace cludg.Repository.NHibernate.Config.Content
{
	public class CommentMap : ClassMap<Comment>
	{
		public CommentMap()
		{
			Table("Comments");
			Cache.ReadWrite();
			Id(x => x.Id).Length(50)
				.GeneratedBy.Custom<Utils.IdentifierGenerator>()
				.Default("");
			References<User>(x => x.Author)
				.Column("AuthorId")
				.LazyLoad();
			Map(x => x.Text).Length(500);
			Map(x => x.DeletedText).Length(500);
			Map(x => x.IsDeleted);
			Map(x => x.CreationTime);
			References<Comment>(x => x.ParentComment)
				.Column("ParentCommentId")
				.LazyLoad();
			References<Story>(x => x.Story)
				.Column("StoryId")
				.LazyLoad();
		}
	}
}
